window.onload = function(){

	lboimg = document.getElementsByTagName('img');
	banner = document.getElementById('banner');
	yuandian = document.getElementsByTagName('li');
	left = document.getElementById('left');
	right = document.getElementById('right');

	num=0;
	function run () {
		for (var i = 0 ; i < lboimg.length; i++) {

			lboimg[i].style.display ='none';
			yuandian[i].style.backgroundColor="#6B6B6B";
		}
		console.log(num);
		lboimg[num].style.display ='block';
		yuandian[num].style.backgroundColor="#fff";


		if(num==lboimg.length-1){
			num=0;
		}else{
			num++;
		}

	}

	o = setInterval(run,1000);
	banner.onmouseover = function(){
		clearInterval(o);
	}
	banner.onmouseout = function(){
		o = setInterval(run,1000);
	}



	for (var x = 0; x < yuandian.length ; x++) {
		add_yuandian(x);
	}

	function add_yuandian (yd){
		yuandian[yd].onclick = function (){
			num = yd;
			run();
		}
	}

	right.onclick = function (){
		run();
	}

	left.onclick = function (){
		if(num==0){               
			num=3;				 
		}else if(num==1){        
			num=4;					/*num 0 为图一的下标  累加等于1  并被置为下标4控制图五*/
		}else{						/*num 4 为图五的下标  累加等于0  并被置为下标3控制图四*/
			num-=2;					/*num 3 为图四的下标  累加等于4     4减2 下标2控制图三*/     
		}							/*num 2 为图三的下标  累加等于3     3减2 下标1控制图二*/ 
		run();						/*num 1 为图二的下标  累加等于2     2减2 下标0控制图一*/	
	}

}